package
{
	import flash.events.MouseEvent;
	import flash.text.TextFormat;
	import flash.text.TextField;
	import com.maliu.utils.ArrayUtil;
	import flash.display.Sprite;

	/**
	 * @author maliu
	 */
	public class Test extends Sprite
	{
		public function Test()
		{
//			var arr:Array = ["a", "b", "c", "d", "e"];
//			var t_arr:Array = ArrayUtil.RandomSort(arr, true);
//			trace(arr);
//			trace(t_arr);
//			var obj:Object = {};
////			obj.line = false;
//			if(obj.line)
//			{
//				trace("ok");
//			}
//			if(obj.line != null)
//			{
//				trace("fuck");
//			}
			
			var formatter:TextFormat = new TextFormat();
			formatter.color = 0xff0000;
			var tf:TextField = new TextField();
			this.addChild(tf);
			tf.defaultTextFormat = formatter;
			tf.text = "fuck you";
			formatter.color = 0x00ff00;
//			tf.setTextFormat(formatter);

//			var vector:Vector = new Vector.<Sprite>[new Sprite(), new Sprite()];
//			var vector:Vector = new Vector.<Sprite>([new Sprite(), new Sprite()]);
			
//			this.removeEventListener(MouseEvent.CLICK, clickHandler);
			
//			var arr:Array = [new ElementObject(1001, "asd", true), new ElementObject(1002, "ss", false), new ElementObject(1000, "asdf", false)];
//			arr.sortOn("id");
//			trace(JSON.stringify(arr));
//			
//			arr = sortByIsOnline(arr);
//			trace(JSON.stringify(arr)); 
//			var obj:Object = {"id":123};
//			var temp:Object = obj;
//			trace(JSON.stringify(obj));
//			trace(JSON.stringify(temp));
//			obj = null;
//			trace(JSON.stringify(obj));
//			trace(JSON.stringify(temp));

//			var test:String = "fuck\nyou\nvery\nmuch";
//			var arr:Array = test.split("\n", 3);
//			trace(test);
//			trace(arr);

			var mytf:TextField = new TextField();
			this.addChild(mytf);
			mytf.htmlText = "<p style='font-family:Consolas;font-size:100%;color:green'>This is a paragraph with some text in it. This is a paragraph with some text in it. This is a paragraph with some text in it. This is a paragraph with some text in it.</p>";
		}
		private function sortByIsOnline(_sourceList:Array):Array
		{
			var t_outLineList:Array = [];
			var t_n:int = _sourceList.length;
			var t_element:ElementObject;
			for(var i:int = t_n-1; i>=0; i--)
			{
				t_element = _sourceList[i];
				if(t_element.isOnline == false)
				{
					t_outLineList.unshift((_sourceList.splice(i, 1))[0]);
				}
			}
			var t_resultList:Array = _sourceList.concat(t_outLineList);
			return t_resultList;
		}
		private function clickHandler(e:MouseEvent):void
		{
			trace("fuck");
		}
	}
}

class ElementObject
{
	public var id:int;
	public var name:String;
	public var isOnline:Boolean;
	
	public function ElementObject(_id:int, _name:String, _isOnline:Boolean)
	{
		id = _id;
		name = _name;
		isOnline = _isOnline;
	}
}